package com.itheima.mapper;

import com.itheima.domain.SysNewUser;
import com.itheima.domain.SysUser;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName:SysUserMapper
 * Package:com.itheima.mapper
 * Description:
 * Date:2021/11/5 18:21
 * Author:liu.min
 */
@Mapper
public interface NewUserMapper {

    //    private int id;
//    private String userName;
//    private String email;
//    private String passWord;
//    private String phoneNum;
//    private List<SysRole> rolelist;
    @Insert("insert into sys_user values(#{id},#{userName},#{email},#{passWord},#{phoneNum})")
    public void save(SysNewUser user);

    @Update("update sys_user set username=#{userName},password=#{passWord} where id=#{id}")
    public void update(SysNewUser user);

    @Delete("delete from sys_user where id=#{id}")
    public void delete(int id);

    @Select("select * from sys_user where id=#{id}")
    @Results({
            @Result(id = true,column = "id",property ="id"),
            @Result(column = "username",property ="userName1" ),
            @Result(column = "password",property ="passWord" ),
            @Result(column = "email",property ="email" ),
            @Result(column = "phonenum",property ="phoneNum" )
    })
    public SysNewUser findById(int id);

    @Select("select * from sys_user")
    @Results({
            @Result(id = true,column = "id",property ="id"),
            @Result(column = "username",property ="userName1" ),
            @Result(column = "password",property ="passWord" ),
            @Result(column = "email",property ="email" ),
            @Result(column = "phonenum",property ="phoneNum" )
    })
    public List<SysNewUser> findAll();

}
